<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>留学生管理系统</title>  
        <link rel="stylesheet" href="${path}/css/admin2.css">
        <style>
         #pay-modal{
                margin: 15% auto;
                padding: 10px;
                width: 400px;
            }
            #payStu-modal{
                margin: 12% auto;
                padding: 10px;
                width: 700px;
                position: relative;
    			z-index: 2000;
    			background: #fff;
            } 
            #addpay-modal{
                margin: 5% auto;
                padding: 10px;
                width: 400px;
                position: relative;
    			z-index: 4000;
    			background: #fff;
            }
            #select{
            	position:absolute;
    			z-index: 2000;
    			margin:-400px 0 0 0;
    			left:50%;
    			transform: translateX(-50%);
            }
            .student{
    			padding: 10px 30px 30px;
    			width: 900px;
    			min-height: 500px;
    			background: #fff;
			}
			th a{
			text-decoration: underline;
            color: #007CBC;
			}
        </style>
        <script>
            var _current_item = "#adminPayManage";
        </script>
        <script type="text/javascript" src="${path}/js/jquery.min.js"></script>
    </head>
    <body>
        <!--header-->
        <div id="above-mask">
            <div class="fileupload pannel hide" id="fileupload-pannel">
                <div class="close-container">
                    <a class="close" onclick="hide('#above-mask, #mask, #fileupload-pannel');">×</a>
                </div>
                <form action="${path}/adminPayManage/fileUpload" method="post" enctype="multipart/form-data" name="fileForm">
                    <div style="margin-top: 30px;"> 上传文件：（支持Excel 97-2003 工作簿 .xls格式文件）</div>
                    <input id="fileCover" class="left" readonly="readonly" placeholder="导入excel文件" type="text" style="width: 280px; height: 22px;">
                    <button onclick="$('#uploadFile').click();return false;" style="background: #aaa">浏览文件</button>
                    <input type="file" name="uploadFile" required="required" id="uploadFile" style="display:none" onchange="$('#fileCover').val($(this).val());">
                    <div>
                        <button type="submit" style="display: block; margin: 0 auto;">提交</button> 
                    </div>
                </form>
            </div>
            <div class="pannel hide" id="pay-modal">
                <div class="close-container">
                    <a class="close" onclick="hide('#mask, #above-mask, #pay-modal')">&times;</a>
                </div>
                
                    <table id="payTab">			
                        <tr>
                            <td ><br />该生未缴费，是否添加缴费记录？<br /><br />
                            <button style="width:60px;margin-left:10px" onclick="hide('#mask, #above-mask, #pay-modal');show('#mask, #above-mask, #payStu-modal')">是</button>
                    		<button style="width:60px;margin-left:40px" onclick="hide('#mask, #above-mask, #pay-modal')">否</button></td>
                        </tr>
                    </table>
            </div>
            <div class="pannel hide" id="payStu-modal">
                <div class="close-container">
                    <a class="close" onclick="hide('#mask, #above-mask, #payStu-modal,#addpay-modal')">&times;</a>
                </div>
                <div style="font-size:22px;padding-left:5px"><label>护照号：</label><label id="passportID"></label>&nbsp;&nbsp;<label>姓名：</label><label id="name"></label></div>
                <br />
                <div style="font-size:18px;color:#113965;padding:5px">已缴费记录：</div>
                    <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>缴费周期</th>
                                    <th>缴费金额</th>
                                    <th>缴费方式</th>
                                    <th>发票日期</th>
                                    <th>备注</th>
                                </tr>
                            </thead>
                           <tbody id="pay_stu">
                            
                            </tbody>
                        </table>
                        <button style="width:100px" id="addPay">添加缴费记录</button>
                        
            </div>
            <div class="pannel hide" id="addpay-modal">
                <div class="close-container">
                    <a class="close" onclick="$('#select').html('');hide('#mask, #above-mask, #addpay-modal')">&times;</a>
                </div>
                    <table class="table table-bordered" id="addpay_stu">
                     <tr><th style="width:100px"><a onclick="createDatatable('#select .stu_1');show('#select .student');makeStringToDictS(this.parentNode.parentNode.lastChild.firstChild.innerHTML,this.parentNode.parentNode.lastChild.firstChild.innerHTML);"><b>学生:</b></a></th><td style="width:300px"><div id="addStu"></div><input type="hidden" id="stuPassportNo" name="passportNo" ></td></tr>
                                <tr><td>缴费周期</td>
                                <td>
                                <input id="pay_one" name="pay_one" style="width:170px" placeholder="必填" required="required">
                        		
                        		</td></tr>
                                <tr><td>缴费金额</td><td><input style="width:165px" type="text" placeholder="必填" required="required" id="pay_money" onKeyUp="this.value=this.value.replace(/[^\.\d]/g,'');this.value=this.value.replace('.','');"></td></tr>
                                <tr><td>缴费方式</td>
                                <td><select id="pay_way" name="pay_way" style="width:170px">
                            		<option >境外汇款</option>
                            		<option >境内银行汇款</option>
                            		<option >自助缴费</option>
                            		<option >教务处缴费</option>
                        			</select></td></tr>
                                <tr><td>发票日期</td><td><input style="width:165px"placeholder="必填" required="required" id="pay_data" type="text"  class="Wdate"  onClick="WdatePicker({dateFmt: 'yyyy-MM-dd'})"></td></tr>
                                <tr><td>备注</td><td><textarea id="remarks" class="form-control" rows="6"></textarea>
                                </td></tr>
                        </table>
                        <div id="select"></div>
                        <button onclick="addpay()">添加</button>
            </div>
        </div>
        <!--student-->
            <div id="student" class="student hide pannel">
                        <div class="close-container"><a class="close" onclick="hide('#student')">×</a></div>
                        <div class="modal-body">
                            <span>专业</span>
                            <select onchange="lookStudent();" id="majorNo">
                                <option>全部</option>
                                <#if allMajorName?exists>
                                <#list allMajorName as r> 
                                <option value="${r.majorNo!}">${r.majorName!}</option>
                                </#list>
                                </#if>
                            </select>
                            <span>入学年份</span>
                            <select onchange="lookStudent();" id="startDate">
                                <option>全部</option>
                                <option>2013</option>
                                <option>2014</option>
                                <option>2015</option>
                                <option>2016</option>
                            </select>

                            <table class="stu_1" id="stu_1">
                                <thead>
                                    <tr>
                                        <td><input type="checkbox" id="checkstudent" onchange="checkAll(this,'#stu_1')"></td> 
                                        <td>学号</td>
                                        <td>护照号</td>
                                        <td>名</td>
                                        <td>姓</td>
                                        <td>专业</td> 
                                        <td>入学年份</td>
                                    </tr>
                                </thead>
                                <tbody>
                                    <#if stuInfo?exists>
                                    <#list stuInfo as r>
                                    <tr>
                                        <td><input type="checkbox" value="${r.passportNo}" newPpn="${r.sNo}" id="studentCheck${r_index}"  onchange="alterStu(this);"></td>
                                        <td>${r.sNo!}</td>
                                        <td>${r.newpassportNo!}</td>
                                        <td>${r.firstName!}</td>
                                        <td>${r.lastName!}</td>
                                        <td>${r.majorName!}</td>
                                        <td>${r.eduStartDate!}</td>
                                    </tr>
                                    </#list>
                                    </#if>
                                </tbody>
                            </table>
                            <button  type="button" onclick="fromDictToString('#addStu','#stuPassportNo');hide('#student');">确定</button>
                        </div>
            </div>
            <!--student end-->
        <div id="mask"></div>
        <div id="header"></div>
        <div id="main">
            <div id="side-menu"></div>
            <div id="container">
                <div id="inner-border">
                    <div>
                        <label>专业</label>
                        <select id="pay_major" name="pay_major">
                            <option value="0">全部</option>
                             <#if allMajorName??>
                                <#list allMajorName as ts>
                            <option value="${ts.majorName}">&nbsp;${ts.majorName}</option>
                            </#list>
                                </#if>
                        </select>
                         <label>班级</label>
                        <select id="clazz" name="clazz">
                            <option value="0">全部</option>
                             <#if allclass??>
                                <#list allclass as cs>
                            <option value="${cs}">&nbsp;${cs}</option>
                            </#list>
                                </#if>
                        </select>
 <script type="text/javascript">
    $().ready(function(){
        $("#clazz option").each(function(index){
            if($(this).attr("value") == 0)
                return;
            var clazzName = $(this).text();
            clazzName = clazzName.substring(clazzName.indexOf(':')+1,clazzName.indexOf('}'));
            $(this).text(clazzName);
            $(this).attr("value",clazzName);
        });
    });
</script>                       
                     <!-- <label>入学年份</label>
                        <select id="pay_year" name="pay_year">
                            <option value="0">全部</option>
                           		<#if allEduStartDate??>
                                <#list allEduStartDate as ts>
                                <option value="${ts.eduStartDate}">&nbsp;${ts.eduStartDate}</option>
                                </#list>
                                </#if>
                        </select> 
                    	<label>入学季度</label>
                        <select id="pay_quar" name="pay_quar">
                            <option value="0">全部</option>
                             <#if allEduSeason??>
                                <#list allEduSeason as ts>
                                <option value="${ts.eduSeason}">&nbsp;${ts.eduSeason}</option>
                                </#list>
                                </#if>
                        </select>   -->
                        <button type="button" style="width:60px" onclick="ajaxsearch()">筛选</button>
                        <button onclick="show('#mask, #above-mask, #fileupload-pannel')">批量导入</button>
                    	<button onclick="window.location.href = '${path}/paymentExport/exportExcel'">批量导出</button>
                    	<button onclick="window.location.href = '${path}/adminPayManage/fileDownload'">模板下载</button>
                    	<button style="background-color:#5CB85C"type="button" onclick="show('#mask, #above-mask,#addpay-modal');newStu()">新建缴费</button>
                    <form action="${path}/adminteamanage/batch" method="post" name="myForm">
                        <input type="hidden" name="checkboxValue" id="checkboxValue">
                        <div id="error" style="display:none">${error!}</div>  
                        <input type="hidden" name="action" value="re"> 
                        <table class="table table-bordered" id="ttable">
                            <thead>
                                <tr>
                                    <th>护照号</th>
                                    <th>学号</th>
                                    <th>姓</th>
                                    <th>名</th>
                                    <th>最后缴费周期</th>
                                    <th>缴费金额</th>
                                    <th>缴费方式</th>
                                    <th>发票日期</th>
                                    <!-- <th>本学期是否缴费</th> -->
                                    <th>缴费状态</th>
                                </tr>
                            </thead>
                            <tbody>
                               <#if payment??>
                            <#list payment as pay>
                                <tr>
                               <td name="passportNo">${pay.newpassportNo!}</td>
                               <td>${pay.sNo!}</td>
                               <td>${pay.lastName!}</td>
                               <td>${pay.firstName!}</td>
                               <td>${pay.paymentData!}</td>
                               <td>${pay.amount!}</td>
                               <td>${pay.payMethod!}</td>
                               <td>${pay.invoiceDate!}</td>
                               <#if pay.paying = "是">
                               <#if pay.current = 1>
                               <td>已缴费</td>
                               <#else>
                               <td>未缴费</td>
                               </#if>
                               <#else>
                               <td>未缴费</td>
                               </#if>
                              <!--  <#if pay.paying = "是">
                               <#if pay.current = 1>
                               <td><button class="edit" style="background-color:#007cbc"type="button" passportNo="${pay.passportNo!}" onclick="pay(this)">已 缴 费</button></td>
                               <#else>
                               <td><button class="edit" style="background-color:#5CB85C"type="button" last="${pay.lastName!}" first="${pay.firstName!}" passportNo="${pay.passportNo!}" newpassportNo="${pay.newpassportNo!}" onclick="nopay(this);">未 缴 费</button></td>
                               </#if>
                               <#else>
                               <td><button class="edit" style="background-color:#5CB85C"type="button" last="${pay.lastName!}" first="${pay.firstName!}"  newpassportNo="${pay.newpassportNo!}" passportNo="${pay.passportNo!}" onclick="nopay(this);">未 缴 费</button></td>
                               </#if> -->
                               
                                </tr>
                                </#list>
                                </#if>
                               
                            </tbody>
                        </table>
                        </form>
                </div>
                
        </div>
        
            </div>
            </div>
            
            <div id="footer"></div>
        <script type="text/javascript" src="${path}/js/admin-main-appearance.js"></script>
        <script type="text/javascript" src="${path}/js/amazeui.min.js"></script>

        <!-- DataTables JavaScript -->
        <script src="${path}/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetHiddenNodes.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTd.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTds.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetColumnData.js"></script>
        <script src="${path}/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
        <script src="${path}/js/linkPage.js"></script>
        <script type="text/javascript" src="${path}/js/My97DatePicker/WdatePicker.js"></script>

        <script type="text/javascript">
            $(document).ready(function () {
                $('#ttable').DataTable({
                    responsive: true,
                    ordering: false,
                    searching: true,
                    "bLengthChange": false,
                    "bRetrieve": true,
                    "bFilter": true//过滤功能
                });
            });
        </script>  
        <script type="text/javascript">
            //填写缴费记录
            function addpay(){
            	var passportNo=$("#stuPassportNo").val();
            	var payone = $("#pay_one").val();
            	var payway = $("#pay_way").find("option:selected").text();//汇款方式
            	var paymoney = $("#pay_money").val();
            	var paydata = $("#pay_data").val();//发票
            	var remarks = $("#remarks").val();
            	if(passportNo==""||payone==""||paymoney==""||paydata==""){
            		alert("请填写完整！");
            	}else{
            		$('#select').html('');
            		hide('#mask, #above-mask, #addpay-modal');
            		 //var passportNo=getCookie("passportNo");
            		 //alert(passportNo);
            		 alert(passportNo);
            		 alert(payway);
            		 $.ajax({
                    type:"post",
                    url:'${path}/paymentManage/addpayment',
                    dataType: "json",
                    data:{
                    		passportNo:passportNo,
                    		paymentData:payone, 
            	  			payMethod:payway, 
            	 			amount:paymoney, 
            	 			invoiceDate:paydata, 
            	 			remarks:remarks,
                    		
                    },
                    success:function(data){
                    alert(JSON.stringify(data));
                    //alert(passportNo);
                     
            		  
         
                    }
                });
            		
            	}
            }
            
            
            function pay(node){
            var passportNo=node.getAttribute("passportNo");
            
            //alert(passportNo);
             $.ajax({
                    type:"post",
                    url:'${path}/paymentManage/ajaxlook',
                    dataType: "json",
                    data:{
                    		passportNo:passportNo,
                    		
                    },
                    datatype:"json",
                    success:function(data){
                   // alert(JSON.stringify(data[0]));
                    $("#passportID").html(data[0].newpassportNo);
                    $("#name").html(data[0].firstName+" "+data[0].lastName);
                    $("#pay_stu").html("");
                    $.each(data,function(num,data){
                    $("#pay_stu").append("<tr><td>"+data.paymentData+"</td><td>"+data.amount+"</td><td>"+data.payMethod+"</td>"+
                               "<td>"+data.invoiceDate+"</td>"+
                               (data.remarks==null?"<td> </td>" :"<td>"+data.remarks+"</td>")+
                               "</tr>");
                    })
                     show('#mask, #above-mask, #payStu-modal');
            		hide('#addPay');
         
                    }
                });
           
          
            }
            
            function nopay(node){
             var passportNo=node.getAttribute("passportNo");
              var newpassportNo=node.getAttribute("newpassportNo");
             var last=node.getAttribute("last");
             var first=node.getAttribute("first");
             //alert(last);
            setCookie("passportNo",passportNo);
            setCookie("last",last);
            setCookie("first",first);
             $("#passportID").html(newpassportNo);
             $("#name").html(first+" "+last);
            show('#mask, #above-mask, #addPay,#pay-modal');
            
            /* var passportNo=getCookie("passportNo");
            alert(passportNo); */
            }
            
            
             function ajaxsearch(){
             alert(1);
             $.ajax({
            		type:"get",
                    url:'${path}/paymentManage/newsearch',
                    data:{
                            majorName:$('#pay_major').val(),
                            clazz:$('#clazz').val(),
                    },
                    datatype:"json",
                    success:function(data){
                   //alert("success");
                    alert(JSON.stringify(data));
                    $('#ttable').dataTable().fnClearTable();
                for (var i = 0; i < data.length; i++){
                if(data[i].paying=="是"){
                if(data[i].current = 1){
                 $('#ttable').dataTable().fnAddData([data[i].newpassportNo,data[i].sNo,data[i].lastName,data[i].firstName,data[i].paymentData,data[i].amount,data[i].payMethod,data[i].invoiceDate,'已 缴 费']);
                }else{
                 $('#ttable').dataTable().fnAddData([data[i].newpassportNo,data[i].sNo,data[i].lastName,data[i].firstName,data[i].paymentData,data[i].amount,data[i].payMethod,data[i].invoiceDate,'未 缴 费']);
                //alert(data[i].passportNo);
                }
                }else{
                 $('#ttable').dataTable().fnAddData([data[i].newpassportNo,data[i].sNo,data[i].lastName,data[i].firstName,data[i].paymentData,data[i].amount,data[i].payMethod,data[i].invoiceDate,'未 缴 费']);
               
                }
                }
                    }
                    
            });
            }
            
            $("#addPay").on("click",function(){
            
            var passportNo=getCookie("passportNo");
            $.ajax({
            type:"post",
                    url:'${path}/paymentManage/ajaxindex',
                    data:{
                            passportNo:passportNo,
                    },
                    datatype:"json",
                    success:function(data){
                   //alert("success");
                   //alert(data);
                   // alert(JSON.stringify(data[0]));
                    $("#pay_one").html("");
                    for(var i=0;i<data.length;i++){
                      $("#pay_one").append('<option value="">'+data[i]+'</option>');
                    } 
                   show('#mask, #above-mask, #addpay-modal');
                    }
            });
            
            })
            
            function lookStudent() {

		                                    var startDate = document.getElementById("startDate").value;
		                                    var majorNo = document.getElementById("majorNo").value;
		
		                                    $.ajax({
		                                        async: false,
		                                        type: "POST",
		                                        url: "${path}/adminCourseManage/lookStudent",
		                                        dataType: "json",
		                                        data: {
		                                            startDate: startDate,
		                                            majorNo: majorNo,
		                                        },
		                                        success: function (data) {
		                                        //alert(JSON.stringify(data));
		                                            $('#stu_1').dataTable().fnClearTable();
		                                            for (var i = 0; i < data.length; i++) {
		                                                $('#stu_1').dataTable().fnAddData(['<input id="studentCheck0" type="checkbox" value="' + data[i]["sNo"] + '" name="studentCheck" onclick="alterStu(this);">', data[i]["sNo"], data[i]["newpassportNo"], data[i]["firstName"], data[i]["lastName"], data[i]["majorName"], data[i]["eduStartDate"]]);
		                                                var ot = $('#stu_1').dataTable();
		                                            }
		                                            checkChecked('#stu_1');
		                                        },
		                                        error: function (err) {
		                                            alert("获取该专业入学年份的学生失败");
		                                        },
		                                    });
		                                }
            function newStu(){
			$("#addStu").html("");
 			//$("#stuPassportNo").val("");
 			//$("#addVisaTime").html("");
 			
 			$("#stuPassportNo").val("");
            $("#pay_one").val("");
            
           $("#pay_money").val("");
            $("#pay_data").val("");//发票
            $("#remarks").val("");
 			$('#select').html($('#student').clone(true));	
    
}
            
        </script>
        <script type="text/javascript">
            $(document).ready(function () {
                if ($("#error").html() != "") {
                    Alert($("#error").html());
                }
                //alert($("#error").html());}
            });
        </script> 
        <script>
            //自动关闭提示框  
            function Alert(str) {
                alert(str);
            }
        </script>
    </body>
</html>
